package com.li.system.controller;

import com.li.common.core.domain.R;
import com.li.system.domain.LoginDTO;
import com.li.system.domain.SysUserSaveDTO;
import com.li.system.domain.SysUserVO;
import com.li.system.service.ISysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 * Date:2025-06-08
 * Time:23:19
 */
@RequestMapping("/sysUser")
@RestController
@Tag(name = "管理员接口")
public class SysUserController {
    @Autowired
    private ISysUserService sysUserService;
    //登陆成功还是失败  失败要告知原因
    //接口文档 统一的响应数据的结构
    @PostMapping("/login")//登陆接口需考虑安全性
    @Operation(summary = "管理员登录", description = "根据账号密码进行管理员登陆")
    @ApiResponse(responseCode = "1000",description = "登陆成功")
    @ApiResponse(responseCode = "2000",description = "服务器繁忙，请稍后重试")
    @ApiResponse(responseCode = "3101",description = "用户不存在")
    @ApiResponse(responseCode = "3103",description = "用户名或密码错误")
    public R<Void> login(@RequestBody LoginDTO loginDTO){
        return sysUserService.login(loginDTO.getUserAccount(),loginDTO.getPassword());
    }

    //添加
    @PostMapping("/add")
    @Operation(summary = "添加管理员",description = "根据提示信息添加管理员")
    @ApiResponse(responseCode = "1000",description = "添加成功")
    @ApiResponse(responseCode = "2000",description = "服务器繁忙，请稍后重试")
    @ApiResponse(responseCode = "3101",description = "用户已存在")
    public R<Void> add(@RequestBody SysUserSaveDTO sysUserSaveDTO){

        return null;
    }

    //删除
    @DeleteMapping("/{userId}")
    @Operation(summary = " 删除⽤⼾", description = "通过⽤⼾id 删除⽤⼾")
    @Parameters(value = {@Parameter(name = "userId", in = ParameterIn.PATH, description = "⽤⼾ID")})
    @ApiResponse(responseCode = "1000", description = " 成功删除⽤⼾")
    @ApiResponse(responseCode = "2000", description = " 服务繁忙请稍后重试")
    @ApiResponse(responseCode = "3101", description = "⽤⼾不存在")
    public R<Void> delete(@PathVariable Long userId) {
        return null;
    }

    //修改
    @PutMapping("/{userId}")
    @Operation(summary = "修改⽤⼾", description = "通过⽤⼾id 修改⽤⼾")
    @Parameters(value = {@Parameter(name = "userId", in = ParameterIn.PATH, description = "⽤⼾ID")})
    @ApiResponse(responseCode = "1000", description = " 修改成功⽤⼾")
    @ApiResponse(responseCode = "2000", description = " 服务繁忙请稍后重试")
    @ApiResponse(responseCode = "3101", description = "⽤⼾不存在")
    public R<Void> update(@PathVariable Long userId, @RequestBody SysUserSaveDTO sysUserSaveDTO) {
        return null;
    }

    @Operation(summary = "⽤⼾详情", description = "根据查询条件查询⽤⼾详情")
    @GetMapping("/detail")
    @Parameters(value = {@Parameter(name = "userId", in = ParameterIn.QUERY, description = "⽤⼾ID"),
    @Parameter(name = "sex", in = ParameterIn.QUERY, description = "⽤⼾性别")})
    @ApiResponse(responseCode = "1000", description = " 成功获取⽤⼾信息")
    @ApiResponse(responseCode = "2000", description = " 服务繁忙请稍后重试")
    @ApiResponse(responseCode = "3101", description = "⽤⼾不存在")
    public R<SysUserVO> detail(@RequestParam(required = true) long userId, @RequestParam(required = false) String sex) {
    return null;
    }
}

